class_name UnitFlyWildPig
extends UnitBase


func pick_new_wander_target():
	# 在矩形范围内随机目标点
	var x_offset = randf_range(-wander_width/2, wander_width/2)
	var y_offset = randf_range(-wander_height/2, wander_height/2)
	target_pos = home_position + Vector2(x_offset, y_offset)
	
	# 下一次切换目标时间
	timer = randf_range(1.0, change_dir_time)
	
	
func play_wander_animation():
	animation_player.play("idle")
	

func on_hit(source: Node2D):
	level.camera.start_shake(unit_data.config.main_attack_cam_shake_intensity, unit_data.config.main_attack_cam_shake_duration)
